_classes = Columns(_CATEGORY_VARIABLE_CDF_);

_firstmoment  = 0;
_secondmoment = 0;
_thirdmoment  = 0;
_fourthmoment  = 0;

_cumprob = 0;

_CATEGORY_VARIABLE_CDF2_ = _CATEGORY_VARIABLE_CDF_;

_latexString = "";
_latexString * 128;

_entropy = 0;

for (_counter = 0; _counter < _classes; _counter = _counter + 1)
{
	_temp = _CATEGORY_VARIABLE_CDF_[0][_counter]*_CATEGORY_VARIABLE_CDF_[1][_counter];
	_entropy = _entropy - Log (_CATEGORY_VARIABLE_CDF_[0][_counter]) * _CATEGORY_VARIABLE_CDF_[0][_counter]; 
	_firstmoment 	= _firstmoment 	+ _temp;
	_temp = _temp * _CATEGORY_VARIABLE_CDF_[1][_counter];
	_secondmoment	= _secondmoment + _temp;
	_temp = _temp * _CATEGORY_VARIABLE_CDF_[1][_counter];
	_thirdmoment	= _thirdmoment + _temp;
	_fourthmoment	= _fourthmoment + _temp * _CATEGORY_VARIABLE_CDF_[1][_counter];
	_cumprob = _cumprob + _CATEGORY_VARIABLE_CDF_[0][_counter];
	_CATEGORY_VARIABLE_CDF2_[0][_counter] = _cumprob;
}

_cw = 0;

for (_counter = 0; _counter < _classes -1 ; _counter = _counter + 1)
{
	_cw = _cw + _CATEGORY_VARIABLE_CDF_[0][_counter];
	if (_CATEGORY_VARIABLE_CDF_[1][_counter+1]-_CATEGORY_VARIABLE_CDF_[1][_counter] > 0.001)
	{
		_latexString * ("&"+Format(_CATEGORY_VARIABLE_CDF_[1][_counter],7,3) +"&"+Format(_cw,7,3));	
		_cw = 0;
	}
}

_cw = _cw + _CATEGORY_VARIABLE_CDF_[0][_counter];
_latexString * ("&"+Format(_CATEGORY_VARIABLE_CDF_[1][_counter],7,3) +"&"+Format(_cw,7,3));	
_latexString*0;
_latexString = _latexString[1][Abs(_latexString)-1];

_counter = _secondmoment-_firstmoment*_firstmoment;

fprintf (stdout, "\nMean     = ", _firstmoment,
				 "\nVariance = ", _counter,
				 "\nCOV      = ", Sqrt(_counter)/_firstmoment,
				 "\nSkewness = ", (2*_firstmoment^3-3*_firstmoment*_secondmoment+_thirdmoment)/Sqrt(_counter)^3,
				 "\nKurtosis = ", (6*_firstmoment^2*_secondmoment-3*_firstmoment^4-4*_firstmoment*_thirdmoment+_fourthmoment)/_counter^2, 
				 "\nEntropy  = ", _entropy, 
				 "\n");


_labels = 0;
_sites  = 0;
_momentMatrix = 0;

